package com.tomecode.tools.maven.settings.model;

/**
 * A download mirror for a given repository.
 * 
 * @author Tomas Frastia
 * @see http://www.tomecode.com or
 *      http://code.google.com/p/maven-settings-editor/
 * 
 */
public final class Mirror {

	private String id;
	/**
	 * The server ID of the repository being mirrored, eg "central". This MUST
	 * NOT match the mirror id.
	 */
	private String mirrorOf;
	/**
	 * The URL of the mirror repository.
	 */
	private String url;
	/**
	 * The optional name that describes the mirror.
	 */
	private String name;

	/**
	 * The layout of the mirror repository. Since Maven 3.
	 */
	private String layout;
	/**
	 * The layouts of repositories being mirrored. This value can be used to
	 * restrict the usage of the mirror to repositories with a matching layout
	 * (apart from a matching id). Since Maven 3.
	 */
	private MirrorOfLayouts mirrorOfLayouts;

	public Mirror() {
		mirrorOfLayouts = MirrorOfLayouts.EMPTY;
	}

	/**
	 * Copy exits {@link Mirror} to new {@link Mirror}
	 * 
	 * @param existsMirror
	 */
	public Mirror(Mirror existsMirror) {
		id = existsMirror.getId();
		url = existsMirror.getUrl();
		name = existsMirror.getName();
		mirrorOf = existsMirror.getMirrorOf();
		mirrorOfLayouts = existsMirror.getMirrorOfLayouts();
		layout = existsMirror.getLayout();
	}

	public final String getId() {
		return id;
	}

	public final void setId(String id) {
		this.id = id;
	}

	public final String getMirrorOf() {
		return mirrorOf;
	}

	public final void setMirrorOf(String mirrorOf) {
		this.mirrorOf = mirrorOf;
	}

	public final String getUrl() {
		return url;
	}

	public final void setUrl(String url) {
		this.url = url;
	}

	public final void setName(String name) {
		this.name = name;
	}

	public final String getName() {
		return name;
	}

	public final String getLayout() {
		return layout;
	}

	public final void setLayout(String layout) {
		this.layout = layout;
	}

	public final MirrorOfLayouts getMirrorOfLayouts() {
		return mirrorOfLayouts;
	}

	public final void setMirrorOfLayouts(String value) {
		this.mirrorOfLayouts = MirrorOfLayouts.parse(value);
	}

}
